﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LogUi.cs" company="" />
// <summary>
//   A logger to both the 'Trace' utility and to present a message-box on the user's UI.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace CryptoQrUtilities
{
    using System;
    using System.Diagnostics;
    using System.Globalization;

    /// <summary>
    /// A logger to both the 'Trace' utility and to present a message-box on the user's UI.
    /// </summary>
    public static class Logger
    {
        /// <summary>
        /// Log an information message.
        /// </summary>
        /// <param name="messageFormat">The message format</param>
        /// <param name="args">Additional arguments if needed.</param>
        public static void LogInfo(string messageFormat, params object[] args)
        {
            string message = string.Format(CultureInfo.InvariantCulture, messageFormat, args);
            string extendedMessage = string.Format("{0}{1}{1}(Hit Ctrl+C to copy this message contents)", message, Environment.NewLine);

            Trace.TraceInformation(message);
        }

        /// <summary>
        /// Log a warning message.
        /// </summary>
        /// <param name="messageFormat">The message format</param>
        /// <param name="args">Additional arguments if needed.</param>
        public static void LogWarning(string messageFormat, params object[] args)
        {
            string message = string.Format(CultureInfo.InvariantCulture, messageFormat, args);

            Trace.TraceWarning(message);
        }

        /// <summary>
        /// Log an error message.
        /// </summary>
        /// <param name="messageFormat">The message format</param>
        /// <param name="args">Additional arguments if needed.</param>
        public static void LogError(string messageFormat, params object[] args)
        {
            string message = string.Format(CultureInfo.InvariantCulture, messageFormat, args);

            Trace.TraceError(message);
        }

        /// <summary>
        /// Log a critical error message.
        /// </summary>
        /// <param name="messageFormat">The message format</param>
        /// <param name="args">Additional arguments if needed.</param>
        public static void LogFatal(string messageFormat, params object[] args)
        {
            string message = string.Format(CultureInfo.InvariantCulture, "FATAL: " + messageFormat, args);

            Trace.TraceError(message);
        }
    }
}
